# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Eric Bélanger <eric@archlinux.org>

pkgname=inetutils
pkgver=2.2
pkgrel=1
pkgdesc="A collection of common network programs"
arch=('x86_64')
url="https://www.gnu.org/software/inetutils/"
license=('GPL3')
depends=('pam' 'libcap' 'readline' 'ncurses' 'libxcrypt'
	     libpam.so libcrypt.so libreadline.so libncursesw.so)
makedepends=('help2man')
backup=('etc/xinetd.d/telnet' 'etc/xinetd.d/talk'
        'etc/xinetd.d/rlogin' 'etc/xinetd.d/rsh'
        'etc/pam.d/rlogin' 'etc/pam.d/rsh')
options=('!emptydirs')
install=inetutils.install
source=("https://ftp.gnu.org/gnu/inetutils/${pkgname}-${pkgver}.tar.xz"{,.sig}
        'ftpd.service' 'rlogin.pam' 'rlogin@.service' 'rlogin.socket' 'rlogin.xinetd'
        'rsh.pam' 'rsh@.service' 'rsh.socket' 'rsh.xinetd' 'talk.service' 'talk.socket'
        'talk.xinetd' 'telnet@.service' 'telnet.socket' 'telnet.xinetd')
sha512sums=('153bc02b2d497f927528f9aac04f16011ec5eb54a3acd98c100dfb6b0b01a63fd1cbc7d2e502b434e38d3ef70208d7a498141b930b1818181343627a525eaeef'
            'SKIP'
            'df5b37c9fc072e012f0e67d849db7e535a62ddb17a37e865acb157f2bc16ffd72d84f24fef1e788dacbbe7e5675e87e141fbd36e53339cc7810dde1b9c54a3b8'
            '432a45af5cd4f9f2dee4b631b45745b734e47cf631553e79db31905fa0839988914bcfed1dfcdd00d2ea6e4029b0674d46623c33ce0bd0678c2628fbaa0d1b25'
            '5c2d1040484f4053cc6e114d38e3a671792c6f196f666a6f6529276d55589870fa9040ac32ac9b521c80c14931b03c97738d2a6ffb50d3a658363a5123ea9e6e'
            '8857dd03794a0ed48b87e6a876c4e17246f3bb4083dc2a9593d8c05d831b03d944d133ae8dc44bc23d1b9d7fe82dd7ab166cb87f53b859a62fc1479e9a49a1de'
            '7091c983bb6d96da3b471fa95d6fdda02cee5b42c4abb93048f7db0d313c17f6c11356cafa835ab4ad01401a30c2169288da2d6a1c4e661c93c36496c04cf507'
            'c957708315ea2d873da55691bb0d0997ee3e2dcb40fb47cef19fd60c25379f1660d0605edd8fb0a477252c5af3e422b44b5e0aaa5b76220dadc90791dd526801'
            'b71e7c25bb1fe3e35420ea3d7eda9b44ed61423ec54973a42a0b5bdac01e8d131aa9656a1e050d74f27723a976fe058a79a04bb34ed70dc5eeb7c49b9be078b4'
            '9fc711b8260f4340188b8f6bc5ac944958d1609a1a506d76b3be917a01caa4493edae89da3c1eaa55294bbddaa6744c68ecb1cd322bb2d74e284d2d6fcd0d2c8'
            '6f5f8b2e1ed24bccfdd08f37d2efca3750d632a5ff4188ed12a10b6cbfe84e85be996020704dfab7b427c023fcc3f328bbda23d69266eba98af0069dcb9de6ea'
            'ca9704da96c457cfb5ca1b5d404470984597af23e5224c53e84c191c98d201b699ad0f712b779a4152b9256e870806b63fefd669bb2532a0f2ef4017bb01b18c'
            '502ca66fb2c0a2df0ea8827c820c199c29a91ab5ccff26866e02a4219007ee7fa36ed4b6001207212db332047a574edc70744e6fcc130d62aab02faa3c9566f7'
            'd440094014d13ca7c3afb4eef735d3526ed8de2cc2de98a48d9682bee9aa197ea750de916c90a6b9e9839529a30b98138fb52427d89e1ee541a87e3401d892b2'
            '6b1f170c1c680bfa2186e0cb3bf555124048c46669bee0265948d22723493b5a23a735f52a8a72304e6cd020dbf2c9991d6cbc4e006bf38dc3b7d6c1addcf1e8'
            '218f2b5686ca0321a9f7a5a991c69b289aa297b7a295e654020636d38fbb5a37d09e720c1e2f950ba14616b0e7dafc2cb6a5e325e3b117dfe0ab3c733b98e5eb'
            '7445417b3cde6dd5a8ad5568c1272ac0b9b4a2375735c707c0cff09ad98a2ba322e6921945b5b1efd0e86212db13eacb5606bd3fa841da9515df5d40f75ad4a2')
# GNU Keyring: https://ftp.gnu.org/gnu/gnu-keyring.gpg
validpgpkeys=(
  '4FBD67621082C4C502448E3B180551BAD95A3C35' # Alfred M. Szmidt <ams@gnu.org>
  '9AA9BDB11BB1B99A21285A330664A76954265E8C' # Simon Josefsson <simon@josefsson.org>
)

build() {
  cd ${pkgname}-${pkgver}
  ./configure \
    --prefix=/usr \
    --libexec=/usr/bin \
    --localstatedir=/var \
    --sysconfdir=/etc \
    --without-wrap \
    --with-pam \
    --enable-ftp \
    --enable-ftpd \
    --enable-telnet \
    --enable-telnetd \
    --enable-talk \
    --enable-talkd \
    --enable-rlogin \
    --enable-rlogind \
    --enable-rsh \
    --enable-rshd \
    --enable-rcp \
    --enable-hostname \
    --enable-dnsdomainname \
    --disable-rexec \
    --disable-rexecd \
    --disable-tftp \
    --disable-tftpd \
    --disable-ping \
    --disable-ping6 \
    --disable-logger \
    --disable-syslogd \
    --disable-inetd \
    --disable-whois \
    --disable-uucpd \
    --disable-ifconfig \
    --disable-traceroute
  make
}

check() {
  cd ${pkgname}-${pkgver}
  make check
}

package() {
  cd ${pkgname}-${pkgver}
  make DESTDIR="${pkgdir}" install

  chmod -s "${pkgdir}"/usr/bin/{rcp,rlogin,rsh}

  install -D -m644 "${srcdir}/telnet.xinetd" "${pkgdir}/etc/xinetd.d/telnet"
  install -D -m644 "${srcdir}/talk.xinetd" "${pkgdir}/etc/xinetd.d/talk"
  install -D -m644 "${srcdir}/rlogin.xinetd" "${pkgdir}/etc/xinetd.d/rlogin"
  install -D -m644 "${srcdir}/rsh.xinetd" "${pkgdir}/etc/xinetd.d/rsh"

  install -D -m644 "${srcdir}/rlogin.pam" "${pkgdir}/etc/pam.d/rlogin"
  install -D -m644 "${srcdir}/rsh.pam" "${pkgdir}/etc/pam.d/rsh"

  install -D -m644 "${srcdir}/ftpd.service" "${pkgdir}/usr/lib/systemd/system/ftpd.service"
  install -D -m644 "${srcdir}/rlogin@.service" "${pkgdir}/usr/lib/systemd/system/rlogin@.service"
  install -D -m644 "${srcdir}/rlogin.socket" "${pkgdir}/usr/lib/systemd/system/rlogin.socket"
  install -D -m644 "${srcdir}/rsh@.service" "${pkgdir}/usr/lib/systemd/system/rsh@.service"
  install -D -m644 "${srcdir}/rsh.socket" "${pkgdir}/usr/lib/systemd/system/rsh.socket"
  install -D -m644 "${srcdir}/talk.service" "${pkgdir}/usr/lib/systemd/system/talk.service"
  install -D -m644 "${srcdir}/talk.socket" "${pkgdir}/usr/lib/systemd/system/talk.socket"
  install -D -m644 "${srcdir}/telnet@.service" "${pkgdir}/usr/lib/systemd/system/telnet@.service"
  install -D -m644 "${srcdir}/telnet.socket" "${pkgdir}/usr/lib/systemd/system/telnet.socket" 
}
